package jk.zmn.thread.status;

/**
 * @author 张梦楠
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2018/5/2615:41
 * @blog www.itzmn.com
 *
 *  yeild会暂停自己
 */
public class YeildThreadDemo extends Thread{
     public static void main(String[] args) {
         YeildThreadDemo yeildThreadDemo = new YeildThreadDemo();
         yeildThreadDemo.start();

         for (int j=0;j<100;j++){
             if (j==50){
                 Thread.yield();
             }
             System.out.println("main--"+j);
         }
     }

    @Override
    public void run() {
        for (int i=0;i<100;i++){
            System.out.println(Thread.currentThread().getName()+i);
        }
    }
}
